﻿namespace MXERP.Shared.Extensions
{
    public static class StreamExtension
    {
        public static byte[] ToBuffer(this Stream stream)
        {
            using var ms = new MemoryStream();
            stream.CopyTo(ms);
            return ms.ToArray();
        }
        public static MemoryStream ToMemoryStream(this Stream stream)
        {
            var ms = new MemoryStream();
            stream.CopyTo(ms);
            return ms;
        }
        public static MemoryStream ToMemoryStream(this byte[] buffer)
        {
            var stream = new MemoryStream(buffer);
            return stream;
        }
    }
}
